#include "MainWindow.h"
#include "ui_MainWindow.h"

#include <QAction>

MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    // 创建新的动作
    QAction* openAction = new QAction(tr("&Open"), this);
    // 添加图标
    QIcon fileOpenIcon(":/myimages/images/fileopen.png");
    openAction->setIcon(fileOpenIcon);
    // 设置快捷键
    openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
    // 在文件菜单中设置新的打开动作
    ui->menuFile->addAction(openAction);

    // 创建新的编辑菜单
    QMenu*   menuEdit   = ui->menuBar->addMenu(tr("编辑(&E)"));
    QAction* findAction = new QAction(tr("&Find"), this);
    QIcon    editFindIcon(":/myimages/images/find.png");
    findAction->setIcon(editFindIcon);
    findAction->setShortcut(QKeySequence(tr("Ctrl+F")));
    menuEdit->addAction(findAction);
}

MainWindow::~MainWindow() {
    delete ui;
}
